home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
Palettes
/
TablePrinter
/
TablePrintPanel.m
< prev
Wrap
Text File
|
1995-06-12
|
2KB
|
65 lines
// TablePrintPanel
//
// By Eric T. Seymour, NeXT Computer, Inc.
//
// TablePrintPanel lets you set the pages per row, so
// that it will adjust the total pages sent to reflect the root page.
// For instance, if I asked to print from 2 to 2 on a table that was three
// pages wide, It would set PrintInfo to print 4 through 6.
//
// You may freely copy, distribute, and reuse the code in this example.
// NeXT disclaims any warranty of any kind, expressed or implied, as to its
// fitness for any particular use.
//
// This file looks best when using tabstops of 3.
#import "TablePrintPanel.h"
@implementation TablePrintPanel:PrintPanel
+ new
{
self = [super new];
pagesPerRow = 1;
return self;
}
- setPagesPerRow:(int)pages
{
pagesPerRow = pages;
return self;
}
- (int)pagesPerRow {return pagesPerRow;}
// Override finalWritePrintInfo to adjust the pages to print to reflect
// the number of pages wide a table might be
- finalWritePrintInfo
{
int originalNumber;
id returnId = [super finalWritePrintInfo];
// Determine the pages to print based on number of pages per row
// and adjust the printinfo object
if ( ![[pageMode cellAt:0:0] state] && pagesPerRow > 1 )
{
if ( originalNumber = [firstPage intValue] )
{
if ( originalNumber >= 1 ) originalNumber--;
else originalNumber = 0;
[[NXApp printInfo] setFirstPage:(originalNumber * pagesPerRow) + 1];
}
if ( originalNumber = [lastPage intValue] )
[[NXApp printInfo] setLastPage:(originalNumber * pagesPerRow)];
}
// Reset PagesPerRow. This must be set for each call to printPSCode.
pagesPerRow = 1;
return returnId;
}
@end